
<?php
	include "../admin/p_usuario/valida_credenciais.php";
	
	$valCr = new valida_credenciais();
	$nivel = array(1,2);
	if(!($valCr->validar($nivel))){
		header('Location: index.php?pg=denied');
	}

?>

<script language="javascript" type="text/javascript" src="../admin/p_anuncio/valida_form.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" src="../admin/lib/js/jquery.maskMoney.js"></script>
<script language="javascript" type="text/javascript" src="../admin/p_anuncio/valida_preco.js"></script>

<div class="form">

	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h2>Adicionar An&uacutencio</h2>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-3">
			<div class="actions">
				<div class="panel panel-default">
					<div class="panel-heading"><h5>Op&ccedil&otildees</h5></div>
					<div class="panel-body">
						<ul class="nav nav-pills nav-stacked">
							<li><a href="index.php?pg=anuncios">Listar An&uacutencios</a></li>
						</ul>
					</div>
				</div>
			</div>			
		</div><!-- end col md 3 -->
		<div class="col-md-9">
		<!-- HEAD DE FORMULÃ�RIO -->
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Formul&aacuterio de Cadastro de An&uacutencio</h5></div>
			<div class="panel-body">
			<!-- FORMULÃ�RIO -->
			<form  method="post" name="form1" action="../admin/p_anuncio/salvar.php" enctype="multipart/form-data">
				<div class="row">
					<div class="col-md-12 form-group"><h6>(<span class="text-danger">*</span>) Campos de preenchimento obrigat&oacuterio.</h6></div>
				</div>
				<div class="row">
					<div class="form-group col-md-9">
						<label for="titulo">T&iacutetulo (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" name="titulo" id="titulo" placeholder="Informe o T&iacute;tulo...">
					</div>
					<div class="form-group col-md-3">
						<label for="preco">Pre&ccedilo (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="preco" name="preco" placeholder="Infome o valor...">
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-12">
						<label for="desc_anuncio">Descri&ccedil&atildeo (<span class="text-danger">*</span>)</label>
    					<textarea rows="5" cols="" class="form-control" id="desc_anuncio" name="desc_anuncio" placeholder="Informe a Descri&ccedil&atilde;o..."></textarea>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-4">
						<label for="tipo_anuncio">Tipo de An&uacutencio (<span class="text-danger">*</span>)</label>
    					<select name="tipo_anuncio" id="tipo_anuncio" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			<?php
									$query = mysql_query("SELECT `id_tipo_anuncio`, `nome_tipo` FROM `tipo_anuncio`");
									while($lista = mysql_fetch_array($query)) { ?> 
									<option value="<?php echo $lista['id_tipo_anuncio']; ?>"><?php echo $lista['nome_tipo']; ?></option>
								<?php }?>
		          		</select>
					</div>
				<?php 
					if($userGroup == 1){?>
					<div class="form-group col-md-4">
						<label for="prioridade">Prioridade</label>
    					<select name="prioridade" id="prioridade" class="form-control">
		          			<option value='selecione'>Selecione...</option>
		          			
		          		</select>
					</div>
				<?php }?>
				</div>
				<div class="row">
					<div class="form-group col-md-6">
						<label for="categoria">Categoria (<span class="text-danger">*</span>)</label>
    					<select name="categoria" id="categoria" class="form-control" onchange="$('#lista2').load('../carregaCombo.php',$(this).parents('form:first').serialize())">
		          			<option value='selecione'>Selecione...</option>
		          			<?php
									$query = mysql_query("SELECT `id_categoria`, `nome_categoria`, `status` FROM `categorias` WHERE `status` LIKE '1'");
									while($lista = mysql_fetch_array($query)) { ?> 
									<option value="<?php echo $lista['id_categoria']; ?>"><?php echo $lista['nome_categoria']; ?></option>
								<?php }?>
		          		</select>
		          		
					</div>
					<div class="form-group col-md-6">
						<label for="subcategoria">Subcategoria (<span class="text-danger">*</span>)</label>
    					<select class="form-control" name="combo2" id="lista2">
    					
    					</select>
					</div>
				</div>
				
				<div class="row">
					<div class="form-group col-md-2">
						<input type="submit" value="Avan&ccedil;ar" class="btn btn-default" name="enviar" onclick="return valida()" >
					</div>
				</div>
			</form>
			</div>
		</div>

		</div><!-- end col md 12 -->
	</div><!-- end row -->
</div>